﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Parallel3M.parallel3m.handler
{
    public class ParallelHandlerContext
    {
        public Hashtable handlers=new Hashtable();

        public ParallelHandlerContext()
        {
            AddHandler(ParallelSystemHandlersConst.CSHARP_RUN_HANDLER, "Parallel3M.parallel3m.handler.CSharpClassRunHandler");
            AddHandler(ParallelSystemHandlersConst.CSHARP_COMPILER_HANDLER, "Parallel3M.parallel3m.handler.CSharpCodeCompileHandler");
        }

        public void AddHandler(string handlerid, string handlerclass)
        {
            handlers.Add(handlerid, handlerclass);
        }

        public ParallelHandler CreateInstance(string handlerid)
        {
            string handlerClass = (string) handlers[handlerid];
            ParallelHandler handler = null;
            if (handlerClass != null)
            {
                handler = (ParallelHandler)Activator.CreateInstance(null, handlerClass).Unwrap();
              
            }
            return handler;
        }

    }
}
